﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;

namespace DAL
{
    public class D_ExperienceType : IDAL.IExperienceType
    {
        WishDayEntities _e;
        public D_ExperienceType() {
            _e = new WishDayEntities();
        }
        public void Add(ExperienceType obj)
        {
            _e.ExperienceType.Add(obj);
            _e.SaveChanges();
        }

        public void Delete(int id)
        {
            _e.ExperienceType.Remove(_e.ExperienceType.Find(id));
            _e.SaveChanges();
        }

        public ExperienceType FindById(int id)
        {
            return _e.ExperienceType.Find(id);
        }

        public List<ExperienceType> GetAll()
        {
            return _e.ExperienceType.ToList();
        }

        public void Update(int id, ExperienceType obj)
        {
            var data = _e.ExperienceType.Find(id);
            data.EName = obj.EName;
            data.EPower = obj.EPower;
            data.IsShow = obj.IsShow;
            _e.SaveChanges();
        }
    }
}
